#include "friplane.h"

Friplane::Friplane()
{
    m_friplane.load(FRI_PATH);
    //初始化坐标
    m_X=GAME_WIDTH*0.5-m_friplane.width()*0.5;
    m_Y=GAME_HEIGHT-m_friplane.height();
    //初始化矩形框
    m_Rect.setWidth(m_friplane.width());
    m_Rect.setHeight(m_friplane.height());
    //发射间隔
    m_recorder=0;
}

void Friplane::shoot()
{
    this->m_recorder++;
    if(m_recorder>BULLET_INTERVAL)
    {
        return;
    }
    m_recorder=0;
    for(int i=0;i<BULLET_NUM;i++)
    {
        if(m_bullet[i].m_Free)
        {
            m_bullet[i].m_Free=false;
            m_bullet[i].m_X=this->m_X;
            m_bullet[i].m_Y=this->m_Y  -  25  ;
            break;
        }
    }
}

void Friplane::setposition(int x, int y)
{
    m_X = x;
    m_Y = y;
    m_Rect.moveTo(m_X, m_Y);
}
